package br.gendi.rcp;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.part.ViewPart;

import br.gendi.dialog.Configuration;

public class NavigationView extends ViewPart {

	public static final String ID = "br.gendi.rcp.navigationView";

    private ToolBar toolBar = null;
    
    public void createPartControl(final Composite parent) {
    	GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = false;
		gridData.verticalAlignment = GridData.BEGINNING;
		
		toolBar = new ToolBar(parent, SWT.FLAT | SWT.WRAP | SWT.H_SCROLL);
		toolBar.setLayoutData(gridData);
		ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
		toolItem.setText("NetMHC");
		toolItem.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/images/computer-laptop-macbook.png")));
		
		ToolItem toolItem1 = new ToolItem(toolBar, SWT.PUSH);
		toolItem1.setText("predTAP");
		toolItem1.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/images/computer-laptop-macbook-black.png")));
		toolItem1.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent arg0) {
			}
			public void widgetSelected(SelectionEvent arg0) {
				Configuration c = new Configuration();
			}
		});
		
		ToolItem toolItem2 = new ToolItem(toolBar, SWT.PUSH);
		toolItem2.setText("Frances");
		toolItem2.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/images/computer-laptop-macbook.png")));
		
		ToolItem toolItem3 = new ToolItem(toolBar, SWT.PUSH);
		toolItem3.setText("Pesquisa 3");
		toolItem3.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/images/computer-laptop-macbook.png")));
		
		ToolItem toolItem4 = new ToolItem(toolBar, SWT.PUSH);
		toolItem4.setText("Pesquisa 1");
		toolItem4.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/images/computer-laptop-macbook.png")));
		
		parent.getShell().addListener(SWT.Resize, new Listener() {
			public void handleEvent(Event e) {
				Rectangle rect = parent.getShell().getClientArea();
				Point size = toolBar.computeSize(rect.width, SWT.DEFAULT);
				toolBar.setSize(size);
			}
		});
    }

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		//viewer.getControl().setFocus();
	}
}